home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / gnuview.zip / emx / book / emxgnu.inf (.txt) next >
OS/2 Help File  |  1996-09-08  |  56KB  |  1,542 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. 1 Introduction to GNU Development Tools Information ΓòÉΓòÉΓòÉ
  3.  
  4.  GNU Development Tools Information 
  5.  
  6.     Copyright (c) 1990-1993 by Eberhard Mattes 
  7.  
  8.  This text describes how to use the GNU C Compiler and other GNU utilities with 
  9.  emx.  For detailed information about GCC, GDB, and GAS, read the GCC, GDB, and 
  10.  GAS manuals, see install.doc.  See build.doc for details on compiling the GNU 
  11.  utilities. 
  12.  
  13.  All programs assume that the entire package is installed on one disk drive in 
  14.  these directories: 
  15.  
  16.           /emx/bin           Executable files
  17.           /emx/etc           termcap.dat
  18.           /emx/lib           Library files
  19.           /emx/include       Header files (C language)
  20.           /emx/include/cpp   Header files (C++ language)
  21.           /emx/include/objc  Header files (Objective C language)
  22.  
  23.  If the /emx directory is not on the current drive, use the C_INCLUDE_PATH and 
  24.  LIBRARY_PATH environment variables, for instance 
  25.  
  26.           set C_INCLUDE_PATH=c:/emx/include
  27.           set LIBRARY_PATH=c:/emx/lib
  28.  
  29.  to use drive C. 
  30.  
  31.  Use forward slashes instead of backward slashes in path names! 
  32.  
  33.  Directories: 
  34.  
  35.           /emx                            Main directory, empty
  36.           /emx/bin                        Executable files and batch files
  37.           /emx/dll                        Dynamic link libraries
  38.           /emx/doc                        Documentation
  39.           /emx/etc                        termcap.dat
  40.           /emx/gnu/binutils.old           old GNU binary utilities (sources)
  41.           /emx/gnu/binutils.26            new GNU binary utilities (sources)
  42.           /emx/gnu/doc                    Documentation
  43.           /emx/gnu/duel                   DUEL (for GDB)
  44.           /emx/gnu/gas-2.6                GNU assembler source (GAS)
  45.           /emx/gnu/gcc-2.7                GNU C compiler source (GCC)
  46.           /emx/gnu/gdb-4.16               GNU debugger source (GDB)
  47.           /emx/gnu/gppdemid               C++ demangler for LINK386
  48.           /emx/gnu/info                   GNU info source
  49.           /emx/gnu/libtxi                 -libtxi  (for GNU info)
  50.           /emx/gnu/libg++-2.7.2           GNU C++ libraries
  51.           /emx/gnu/makeinfo               GNU makeinfo source
  52.           /emx/gnu/termcap                GNU termcap
  53.           /emx/gnu/texindex               GNU texindex source
  54.           /emx/include                    header files (C language)
  55.           /emx/include/cpp                Header files (C++ language)
  56.           /emx/include/objc               Header files (Objective C language)
  57.           /emx/lib                        Libraries
  58.  
  59.  
  60. ΓòÉΓòÉΓòÉ 2. 2 GCC -- compiling and linking C and C++ programs ΓòÉΓòÉΓòÉ
  61.  
  62.  GCC 2.7.2.1 has been ported to emx, including Richard W.M. Jones's bounds 
  63.  checking patches. 
  64.  
  65.   Calling GCC
  66.   Environment variables
  67.   Bounds checking
  68.   #pragma statement
  69.   Additional command line options
  70.   Special file extensions
  71.   Startup modules and libraries
  72.   Assertions
  73.   C++
  74.   Objective C
  75.   Stack probes
  76.   Other changes
  77.   Calling conventions
  78.  
  79.  
  80. ΓòÉΓòÉΓòÉ 2.1. 2.1 Calling GCC ΓòÉΓòÉΓòÉ
  81.  
  82.  For small projects, one invokation GCC can be used to compile and link the 
  83.  program.  Example: 
  84.  
  85.           gcc dwim.c
  86.  
  87.  This assumes that emxl.exe can be found in one of the directories listed in 
  88.  the EMXPATH and PATH environment variables, or in the directory /emx/bin, see 
  89.  also ld.  If no output file name is given, the name of the first input file, 
  90.  with .exe extension (or .dll extension if -Zdll is given), is used for the 
  91.  output file unless linking is suppressed (with the -c option, for instance). 
  92.  That is, the above example creates dwim.exe. 
  93.  
  94.  Please note that the example given above creates a file named dwim which will 
  95.  be deleted after conversion to .exe format. 
  96.  
  97.  If the output file name doesn't end in .exe or .dll, the output file will have 
  98.  a.out format (however, see -Zexe).  Example: 
  99.  
  100.           gcc -o dwim dwim.c
  101.  
  102.  This example creates the a.out file `dwim'. 
  103.  
  104.  
  105. ΓòÉΓòÉΓòÉ 2.2. 2.2 Environment variables ΓòÉΓòÉΓòÉ
  106.  
  107.  If you want to develop programs on a drive different from the drive where emx 
  108.  is installed, you have to set the C_INCLUDE_PATH and LIBRARY_PATH environment 
  109.  variables, for instance, 
  110.  
  111.           set C_INCLUDE_PATH=c:/emx/include
  112.           set LIBRARY_PATH=c:/emx/lib
  113.  
  114.  If you want to compile C++ programs, set CPLUS_INCLUDE_PATH as well: 
  115.  
  116.           set CPLUS_INCLUDE_PATH=c:/emx/include/cpp;c:/emx/include
  117.  
  118.  If you want to compile Objective C programs, set OBJC_INCLUDE_PATH as well: 
  119.  
  120.           set OBJC_INCLUDE_PATH=c:/emx/include
  121.  
  122.  The genclass utility needs the following environment variable: 
  123.  
  124.           set PROTODIR=c:/emx/include/cpp/gen
  125.  
  126.  If the TMPDIR, TMP and TEMP environment variables are not set, GCC writes 
  127.  temporary files in the current working directory.  GCC tries TMPDIR, TMP and 
  128.  TEMP in turn and uses the first valid one.  Note that c: is not a valid 
  129.  directory name, you have to use c:/ or \ instead.  In other cases, a trailing 
  130.  slash or backslash is optional.  For instance, use 
  131.  
  132.           SET TMPDIR=f:/tmp/
  133.  
  134.  to put temporary files into the f:/tmp directory. 
  135.  
  136.  When compiling projects consisting of many modules (such as libraries) under 
  137.  OS/2, you can speed up compilation if you have enough memory by keeping GCC in 
  138.  memory.  For example, to keep GCC in memory for 5 minutes, use 
  139.  
  140.           set GCCLOAD=5
  141.  
  142.  The following programs use GCCLOAD: gcc.exe, cpp.exe, cc1.exe, cc1plus.exe, 
  143.  cc1obj.exe, as.exe and emxomf.exe. 
  144.  
  145.  You can put GCC options into the environment variable GCCOPT.  These options 
  146.  will be read before the options given on the command line.  For example, to 
  147.  use -pipe, type 
  148.  
  149.           set GCCOPT=-pipe
  150.  
  151.  
  152. ΓòÉΓòÉΓòÉ 2.3. 2.3 Bounds checking ΓòÉΓòÉΓòÉ
  153.  
  154.  The emx port of GCC includes Richard W.M. Jones's bounds checking patches. 
  155.  See the GCC manual and \emx\gnu\doc\bounds\README for details.  The complete 
  156.  report is in \emx\gnu\doc\bounds\bcrep2.ps (shipped in gnudoc.zip).  Use 
  157.  GhostScript if you don't have a PostScript printer. 
  158.  \emx\gnu\doc\bounds\bcreport.txt contains important excerpts from an earlier 
  159.  version of the report as plain ASCII text. 
  160.  
  161.  There are a few additional restrictions under OS/2: 
  162.  
  163.      Bounds checking is not available for multithread programs 
  164.  
  165.      Bounds checking is available for statically linked programs only 
  166.  
  167.      Bounds checking is not available for DLLs 
  168.  
  169.      If your program uses _tmalloc(), you have use the -ltmalloc option as the 
  170.       bounds checking library check.a replaces malloc() 
  171.  
  172.  The header files <stdarg.h> and <varargs.h> automatically include <fix-args.h> 
  173.  if bounds checking is enabled.  Therefore you don't have to include 
  174.  <fix-args.h> yourself. 
  175.  
  176.  
  177. ΓòÉΓòÉΓòÉ 2.4. 2.4 #pragma statement ΓòÉΓòÉΓòÉ
  178.  
  179.  The emx port of GCC supports the 
  180.  
  181.      #pragma pack(n) 
  182.  
  183.  statement where n is 1, 2 or 4.  The default is 4.  Structure fields are 
  184.  aligned to multiples of n bytes, according to the value n as set by the last 
  185.  #pragma pack statement. 
  186.  
  187.           #pragma pack()
  188.  
  189.  reverts to the default (4).  Note that other C compilers revert to the value 
  190.  in effect before the previous #pragma pack statement. 
  191.  
  192.  
  193. ΓòÉΓòÉΓòÉ 2.5. 2.5 Additional command line options ΓòÉΓòÉΓòÉ
  194.  
  195.  Several command line options have been added to GCC: 
  196.  
  197.  -mepilogue 
  198.  
  199.      emit only one epilogue per function 
  200.  
  201.  -mno-epilogue 
  202.  
  203.      emit multiple epilogues per function if appropriate (default) 
  204.  
  205.  -mprobe 
  206.  
  207.      generate stack probes 
  208.  
  209.  -mno-probe 
  210.  
  211.      do not generate stack probes (default) 
  212.  
  213.  -pn 
  214.  
  215.      Enable profiling but do not generate profile hooks 
  216.  
  217.  -Zbin-files 
  218.  
  219.      open files in binary mode by default 
  220.  
  221.  -Zbsd-signals 
  222.  
  223.      select the `BSD' signal processing model 
  224.  
  225.  -Zcrtdll 
  226.  
  227.      link the C library dynamically 
  228.  
  229.  -Zdll 
  230.  
  231.      create a dynamic link library 
  232.  
  233.  -Zexe 
  234.  
  235.      touch output file, add .exe extension 
  236.  
  237.  -Zmap 
  238.  
  239.      let LINK386 or emxbind create a .map file 
  240.  
  241.  -Zlink